package com.yeung;

import java.text.DecimalFormat;
import java.text.NumberFormat;

public class FormatUtils {
    /**
     * 格式化数字
     *
     * @param number
     * @return
     */
    public static String formatNumber(Double number) {
        DecimalFormat df = new DecimalFormat(".##");
        String format = df.format(number);
        return format;
    }

    public static String formatNumber3(Double number) {
        String result = String.format("%.2f", number);
        return result;
    }

    public static String formatNumber2(Double number, int count) {
        NumberFormat ddf1 = NumberFormat.getNumberInstance();
        ddf1.setMaximumFractionDigits(2);
        String s = ddf1.format(number);
        return s;
    }


}
